Skip to content

Require explicit acknowledgement for risky Rust call analysis#2715

Closed
sumitshahorg wants to merge 6 commits intogoogle:mainfrom
sumitshahorg:fix/rust-call-analysis-acknowledgement
Closed

Require explicit acknowledgement for risky Rust call analysis#2715
sumitshahorg wants to merge 6 commits intogoogle:mainfrom
sumitshahorg:fix/rust-call-analysis-acknowledgement

Conversation

@sumitshahorg
Copy link
Copy Markdown

@sumitshahorg sumitshahorg commented Apr 11, 2026

Summary

Introduce a safety guard for Rust call analysis to prevent unintended execution of untrusted code during scanning, explicitly addressing a Remote Code Execution (RCE) risk.

Problem

When --call-analysis=rust is enabled, the scanner invokes cargo build, which executes build.rs scripts. These scripts can contain arbitrary code and are executed automatically during the build process.

This creates a Remote Code Execution (RCE) risk where scanning an untrusted project can lead to arbitrary code execution on the host system without explicit user awareness.

Solution

  • Add a required flag: --allow-risky-rust-call-analysis
  • Fail fast if Rust call analysis is requested without explicit acknowledgement
  • Add documentation warning in README about execution of build.rs

Behavior Change

Before:

--call-analysis=rust
→ cargo build executes automatically
→ build.rs may execute arbitrary code (RCE risk)

After:

--call-analysis=rust
→ fails unless --allow-risky-rust-call-analysis is provided
→ explicit user acknowledgement required

Security Impact

  • Prevents silent Remote Code Execution (RCE) via build.rs
  • Eliminates implicit execution of untrusted code during scanning
  • Introduces explicit user consent for risky operations
  • Aligns with secure-by-default and least-astonishment principles

Notes

This change does not alter functionality when explicitly enabled, but enforces a secure default by requiring user acknowledgement before executing potentially unsafe build steps.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 11, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Add --allow-risky-rust-call-analysis and fail fast when --call-analysis=rust is enabled without explicit trust acknowledgement. Also add README warning and a small explanatory comment near the guard.
@sumitshahorg sumitshahorg force-pushed the fix/rust-call-analysis-acknowledgement branch from 464c7ab to 7d8b3a0 Compare April 11, 2026 14:00
Copy link
Copy Markdown
Author

@sumitshahorg sumitshahorg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests validating the Rust call-analysis safety guard.

@Ly-Joey
Copy link
Copy Markdown
Contributor

Ly-Joey commented Apr 24, 2026

Hi @sumitshahorg, thank you for your interest in contributing!

We have already documented the potential risks of running rust call analysis on untrusted project in our documentation and the --call-analysis flag usage description.
Given rust call analysis is still an experimental feature, we currently don't see a need to add the warning to our README.md.

Additionally, your idea of requiring an explicit allow-flag is implemented in osv-scalibr #1730. However, because adding the same flag to osv-scanner will be a breaking change, we will only be able to include it in the osv-scanner v3 release.

Thanks again for raising the concerns and PR! Please be assured that we are aware of this risk and are working towards stronger guardrails for risky plugins.

@Ly-Joey Ly-Joey closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants